/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tictactoe;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
 *
 * @author Kevin O
 */
public class MenuPanel extends JPanel implements ActionListener{
    ActionListener action_listener;
    
    //Menu Buttons
    JButton newgame_button;
    JButton undo_button;
    JButton redo_button;
    JButton options_button;
    
    //Radio Buttons for Rotating the board
    ButtonGroup rotation_group;
    JLabel rotation_label;
    JRadioButton wx_radio;
    JRadioButton wy_radio;
    JRadioButton wz_radio;
    JRadioButton xy_radio;
    JRadioButton xz_radio;
    JRadioButton yz_radio;
    
    public MenuPanel(){
        //Initialize buttons
        newgame_button = new JButton("New Game");
        newgame_button.addActionListener(this);
        undo_button = new JButton("Undo");
        undo_button.addActionListener(this);
        undo_button.setEnabled(false);
        redo_button = new JButton("Redo");
        redo_button.addActionListener(this);
        redo_button.setEnabled(false);
        options_button = new JButton("Options");
        options_button.addActionListener(this);
        
        //Initialize Board Rotations radio buttons
        rotation_label = new JLabel("Sub-Board Coordinates");
        wx_radio = new JRadioButton("W / X");
        wx_radio.addActionListener(this);
        wx_radio.setSelected(true);
        wy_radio = new JRadioButton("W / Y");
        wy_radio.addActionListener(this);
        wz_radio = new JRadioButton("W / Z");
        wz_radio.addActionListener(this);
        xy_radio = new JRadioButton("X / Y");
        xy_radio.addActionListener(this);
        xz_radio = new JRadioButton("X / Z");
        xz_radio.addActionListener(this);
        yz_radio = new JRadioButton("Y / Z");
        yz_radio.addActionListener(this);
        
        //Set up the group of Radio Buttons
        rotation_group = new ButtonGroup();
        rotation_group.add(wx_radio);
        rotation_group.add(wy_radio);
        rotation_group.add(wz_radio);
        rotation_group.add(xy_radio);
        rotation_group.add(xz_radio);
        rotation_group.add(yz_radio);
        
        //Set up the layout
        GridLayout gridlayout = new GridLayout(11, 1);
        setLayout(gridlayout);
        
        //Add all of the elements
        add(newgame_button);
        add(undo_button);
        add(redo_button);
        add(rotation_label);
        add(wx_radio);
        add(wy_radio);
        add(wz_radio);
        add(xy_radio);
        add(xz_radio);
        add(yz_radio);
        add(options_button);
    }
    
    @Override 
    public void actionPerformed(ActionEvent e){
        
        if (e.getSource() == newgame_button)
            System.out.println("Game.NewGame()");
        
        else if (e.getSource() == undo_button)
            System.out.println("Game.Undo()");
        
        else if (e.getSource() == redo_button)
            System.out.println("Game.Redo()");
        
        else if (e.getSource() == wx_radio)
            System.out.println("OutputPanel.Rotate(0)");
        
        else if (e.getSource() == wy_radio)
            System.out.println("OutputPanel.Rotate(1)");
        
        else if (e.getSource() == wz_radio)
            System.out.println("OutputPanel.Rotate(2)");
        
        else if (e.getSource() == xy_radio)
            System.out.println("OutputPanel.Rotate(3)");
        
        else if (e.getSource() == xz_radio)
            System.out.println("OutputPanel.Rotate(4)");
        
        else if (e.getSource() == yz_radio)
            System.out.println("OutputPanel.Rotate(5)");
        
        else if (e.getSource() == options_button)
            System.out.println("Call options dialog");
        
        
    }
}
